<template>
    <div class="mod-prod-prodTag">
        <avue-crud ref="crud"
           :page="page"
           :data="dataList"
           :table-loading="dataListLoading"
           :option="tableOption"
           @search-change="searchChange"
           @on-load="getDataList"
           @refresh-change="refreshChange">
            <template slot-scope="scope"
                      slot="menu">
                <el-button type="primary"
                   icon="el-icon-search"
                   size="small"
                   @click="openOldYears(scope.row)">历年查询</el-button>
            </template>
        </avue-crud>
        <old-years ref="oldYearsRef"></old-years>
    </div>
</template>

<script>
import OldYears from './OldYears.vue'
import { tableOption } from '@/crud/manage/company'
export default {
    components: {
        OldYears
    },
    data () {
        return {
            page: {
                total: 0, // 总页数
                currentPage: 1, // 当前页数
                pageSize: 100 // 每页显示多少条
            },
          dataList: [
            { custom: "客户1",dept:"销售一部",man:"张三", id: 1, type: 0, "1": 10000, year: "2025",
            },
            { custom: "客户2", type: 0 },
            { custom: "客户3", type: 0 },
          ],
            dataListLoading: false,
            tableOption: tableOption,
            permission: {
                delBtn: this.isAuth('prod:prodTag:delete')
            },
        }
    },
    created () {
    },
    mounted () {
    },
    methods: {
        openOldYears(){
            this.$refs.oldYearsRef.init()
        },
        getDataList (page, params, done) {
            this.dataListLoading = true
            this.$http({
                url: this.$http.adornUrl('/prod/prodTag/page'),
                method: 'get',
                params: this.$http.adornParams(Object.assign({
                    current: page == null ? this.page.currentPage : page.currentPage,
                    size: page == null ? this.page.pageSize : page.pageSize
                }, params))
            }).then(({ data }) => {
                // this.dataList = data.records
                this.page.total = data.total
                this.dataListLoading = false
                if (done) {
                    done()
                }
            })
        },
        // 新增 / 修改
        addOrUpdateHandle (id) {
            this.addOrUpdateVisible = true
            this.$nextTick(() => {
                this.$refs.addOrUpdate.init(id)
            })
        },
        deleteHandle (id) {
            this.$confirm('确定进行删除操作?', '友情提醒', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$http({
                    url: this.$http.adornUrl('/prod/prodTag/' + id),
                    method: 'delete',
                    data: this.$http.adornData({})
                }).then(({ data }) => {
                    this.$message({
                        message: '操作成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                            this.getDataList(this.page)
                        }
                    })
                })
            }).catch(() => { })
        },
        /**
         * 刷新回调
         */
        refreshChange () {
            this.getDataList(this.page)
        },
        searchChange (params, done) {
            this.getDataList(this.page, params, done)
        }
    }
}
</script>

<style lang="scss" scoped>
</style>
